<?xml version="1.0" encoding="UTF-8" ?>

<!-- New document created with EditiX at Fri Nov 25 19:15:05 WET 2011 -->

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
	<xsl:output method="html" indent="yes"/>
	
    <xsl:param name="query"/>
	<xsl:param name="type">html</xsl:param>
	
	<xsl:template match="/">
	 <xsl:choose>
            <xsl:when test="$type = 'html'">
	<html>
		<head>
			<title>XpertStats XML - Team Details</title>
			<link href="css/bluedream.css" media="screen" rel="stylesheet" type="text/css" />
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<link rel="shortcut icon" href="images/logo.ico" />
			<link rel="icon" type="image/gif" href="images/logo.ico" />
			<script type="text/javascript"> 
					 	var query = '<xsl:value-of select="$query"/>';
					 	var xslFile = "xslt/team_page.xslt";
					 	var xmlFile = "team_data.xml"
			</script>
			<script type="text/javascript" src="js/XSLT-sort.js"/> 
		</head>
		<body>
		<div id="wrapper">
			<div id="header">
				<div id="header_content">
					<img src="./images/logo.png"/>
					<div style="float:right; margin-top: 15px;">
				   	<form name="form" id="searchbox">
						<select id="steam" onchange="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)">
						<xsl:for-each select="*/team">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="@id" /></xsl:attribute>
								<xsl:value-of select="name"/>
							</option>
						</xsl:for-each>					
						
						</select>
				                    <input type="button" value="pesquisar" onclick="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)"/>
					</form>
					</div>					
				</div>
				
			</div>  
			<div id="menuStrip">
				<ul class="menu">
					  <li><a href="stadiums_data.xml"><span>Stadiums</span></a></li>
					  <li><a href="teams_data.xml"  class="active"><span>Teams</span></a></li>
					  <li><a href="players_data.xml"><span>Players</span></a></li>
					  <li><a href="fixtures_data.xml"><span>Fixtures</span></a></li>
				</ul>    
			</div>
			

			<xsl:apply-templates select="//team[@id = $query]" />
		

		</div>
		<div id="footer">
			<div id="footerD">
				<div id="footerF" class="aligned">XpertStats XML - Desenvolvido no âmbito da cadeira CTXML 2011 @ FCT-UNL</div>
				<div id="footerS" class="aligned">Por: Ricardo Mestre e Nuno Gomes</div>
			</div>
		</div>    
	</body>
		</html>
	</xsl:when>
	
    <xsl:when test="$type = 'newHTML'">
    
	   <div id="wrapper">		
            <div id="header">
				<div id="header_content">
					<img src="./images/logo.png"/>
					<div style="float:right; margin-top: 15px;">
				   	<form name="form" id="searchbox">
						<select id="steam" onchange="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)">
						<xsl:for-each select="*/team">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="@id" /></xsl:attribute>
								<xsl:value-of select="name"/>
							</option>
						</xsl:for-each>					
						
						</select>
				                    <input type="button" value="Search" onclick="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)"/>
					</form>
					</div>					
				</div>
				
			</div>  
			<div id="menuStrip">
				<ul class="menu">
					  <li><a href="stadiums_data.xml"><span>Stadiums</span></a></li>
					  <li><a href="teams_data.xml"  class="active"><span>Teams</span></a></li>
					  <li><a href="players_data.xml"><span>Players</span></a></li>
					  <li><a href="fixtures_data.xml"><span>Fixtures</span></a></li>
				</ul>    
			</div>
			<xsl:apply-templates select="//team[@id = $query]" />
        </div>            
            </xsl:when>
	           <xsl:otherwise>
	                <xsl:apply-templates select="//team[@id = $query]"/>
	            </xsl:otherwise>
	        </xsl:choose>
	</xsl:template>
	
	
	<xsl:template match="team">
	<div id="main" style="padding-top: 10px;">  
		<section  class="team">
			<img>
				<xsl:attribute name="src">images/teams/t<xsl:value-of select="substring-after(@id,'team_')"/>.png</xsl:attribute>
				<xsl:attribute name="alt"><xsl:value-of select="stadium"/></xsl:attribute>
			</img>
			<ul>
				<li><span>Name: </span><xsl:value-of select="name"/></li>
				<li><span>Foundation: </span><xsl:value-of select="foundation"/></li>
				<li><span>Acronym: </span><xsl:value-of select="acronym"/></li>
				<li><span>City: </span><xsl:value-of select="city"/></li>
				<li><span>Stadium: </span><xsl:value-of select="stadium"/></li>
				<li><span>Website: </span><a>
				<xsl:attribute name="href"><xsl:value-of select="website"/></xsl:attribute>
				<xsl:value-of select="website"/></a></li>
				<li><span>Description: </span><xsl:value-of select="description"/></li>
				
			</ul>
		</section>
		<section  class="lineup">
			<h2>Squad</h2>
			<table style="margin-left:30px;" class="geral">
				<thead>
					<tr>
						<th>Shirt</th>
                        <th>NickName</th>
                        <th>Name</th> 
                        <th>Position</th>
                        <th>Nacionality</th>                                                
					</tr>
				</thead>
				<tbody>
                    
				<xsl:for-each select="squad/player">			
					<tr>
						<td><xsl:value-of select="playerNumber"/></td>
						<td>
							<a href="javascript:viewPlayer('{@id}')"><xsl:value-of select="nickname"/></a></td>
						<td><xsl:value-of select="name"/></td>
						<td><xsl:value-of select="position"/></td>
						<td><xsl:value-of select="nacionality"/></td>
					</tr>
					</xsl:for-each>
				</tbody>
			</table>
		</section>
		<section class="history">
			<h2>Awards</h2>
			<ul>
			<xsl:for-each select="history/award">
				<xsl:sort select="date" order="descending"/>
				<li><span><xsl:value-of select="date"/> </span><xsl:value-of select="title"/></li>
			</xsl:for-each>
			</ul>		
		</section>
		
		<aside>
			<img>
				<xsl:attribute name="src">images/stadiums/<xsl:value-of select="substring-after(stadium/@stadiumId,'stadium_')"/>.jpg</xsl:attribute>
				<xsl:attribute name="alt"><xsl:value-of select="stadium"/></xsl:attribute>
			</img>
		</aside>
	</div>
	</xsl:template>

</xsl:stylesheet>
